package com.theme.passport.controller.app;

import com.theme.common.mvc.utils.PageUtils;
import com.theme.common.mvc.view.R;
import com.theme.passport.entity.constant.ThemeStatusEnum;
import com.theme.passport.service.theme.RecommendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;


/**
 * APP 推荐轮播图接口
 *
 * @author live
 * @email 870459550@qq.com
 * @date 2023-02-28 11:50:56
 */
@RestController
@RequestMapping("app/recommend")
@Api("推荐轮播图接口")
public class AppRecommendController {

    @Autowired
    private RecommendService recommendBannerService;

    @GetMapping("list")
    @ApiOperation("获取今日推荐Banner列表 返回Type 类型 type 1主题，2壁纸，3组件")
    public R list(@RequestParam(value = "keyword", required = false) String keyword,
                  @RequestParam(value = "type", required = false) String type,
                  @RequestParam(value = "classify", defaultValue = "2") String classify,
                  @RequestParam(value = "page", defaultValue = "1") String page,
                  @RequestParam(value = "limit", defaultValue = "10") String limit) {

        Integer status = ThemeStatusEnum.NORMAL.getValue();
        Map<String, Object> params = new HashMap<>();
        params.put("status", String.valueOf(status));
        params.put("key", keyword);
        params.put("type", type);
        params.put("classify", classify);
        params.put("page", page);
        params.put("limit", limit);
        PageUtils pages = recommendBannerService.queryPage(params);

        return R.ok().put("page", pages);
    }

}
